/*
 * PegGameDATA.java
 *
 * Created on October 7, 2007, 2:52 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package peggame;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

/**
 *
 * @author Eric Drucker
 */
public class PegGameDATA
{
	
	/**
	 * size of the board
	 */
	public static final int BOARD_SIZE = 5;
	
	/**
	 * sets the goal number to win - used for GENIUS level of play (leaving 8 with no possible moves)
	 */
	public static final int FINAL_NUM = 1;
	
	/** Creates a new instance of PegGameDATA */
	public PegGameDATA()
	{
	}
	
	/**
	 * Text-based version of the game, useful for testing logic
	 */
	public static void main(String[] args) throws IOException
	{
		PegGameBoard p = new PegGameBoard();
		System.out.println(p);
		BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
		
		System.out.println("Enter row of first removed peg");
		int row0 = Integer.parseInt(in.readLine());
		System.out.println("Enter column of first removed peg");
		int col0 = Integer.parseInt(in.readLine());
		
		p.removeFirstPeg(new int[] {row0, col0});
		
PegGameAI ai = new PegGameAI();
		
		while(p.numMovesAvailable() > 0)
		{
			ArrayList<int[][]> moves = ai.getAvailableMoves(p.getPegs());
			
			for(int i = 0; i < moves.size(); i++)
			{
				int[][] temp = moves.get(i);
				System.out.print(Arrays.toString(temp[0]) + " ");
				System.out.print(Arrays.toString(temp[1]) + "\n");
				
			}
			
			System.out.println("\n\nBest Available Move: ");
			int[][] temp = ai.getNextMove(p.getPegs());
			System.out.print(Arrays.toString(temp[0]) + " ");
			System.out.print(Arrays.toString(temp[1]) + "\n\n");
			
			
			System.out.println("Enter row of start position");
			int row1 = Integer.parseInt(in.readLine());
			System.out.println("Enter column of start postition");
			int col1 = Integer.parseInt(in.readLine());
			System.out.println("Enter row of finish position");
			int row2 = Integer.parseInt(in.readLine());
			System.out.println("Enter column of finish position");
			int col2 = Integer.parseInt(in.readLine());
			
			p.move(new int[] {row1, col1}, new int[] {row2, col2});
			
			System.out.println(p);
		}
		
		System.out.println("\n\n\n");
		System.out.println("GAME OVER");
		//System.out.println("Score: " + p.numPegsLeft());
	}
}
